<?php 
include_once("public/head.php");
$b = isset($_GET['fenlei'])?$_GET['fenlei']:"%";
@mysql_connect('localhost', 'root', 'root');
mysql_select_db('blog');
mysql_set_charset('utf8');
$sql = "select * from `writing` where `fenlei` like '$b' ";
$res = mysql_query($sql);
while ($rows = mysql_fetch_assoc($res)) {
    $arr[] = $rows;
}

?>

  <div class="jztop"></div>
  <div class="container">
    <div class="bloglist f_l">
      <?php 
      if (isset($arr)) {
       
      
       foreach ($arr as $v) {

     echo 	'<h3><a href="xiangqing.php?id='.$v['id'].'">'.$v['title'].'</a></h3>
      <figure><img src="/public/pic/'.$v['pic'].'" alt=""></figure>
      <ul>
        <p> '.mb_substr(strip_tags($v['content']) , 0,50).'</p>
        <a  href="xiangqing.php?id='.$v['id'].'" target="_blank" class="readmore">阅读全文&gt;&gt;</a>
      </ul>
      <p class="dateview"><span>'.date('Y-m-d h:i:s',$v['ctime']) .'</span><span>作者：朱雄</span><span>点击量：'.$v['dianji'].'</span></p>';
        }
      }
      else{
        die("<script>alert('没有内容');window.location.href='index.php'</script>");
      }
       ?>
      }


    </div>
    <div class="r_box f_r">
      <div class="tit01">
        <h3 class="tit">关注我</h3>
        <div class="gzwm">
          <ul>
            <!-- <li><a class="email" href="#" target="_blank">我的电话</a></li> -->
            <li><a class="qq" href="http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&email=hbC1trawtbC2s8X09Kvm6ug" target="_blank">我的邮箱</a></li>
            <li><a class="tel" href="https://user.qzone.qq.com/503350536/infocenter" target="_blank">我的QQ空间</a></li>
            <!-- <li><a class="prize" href="#">个人奖项</a></li> -->
          </ul>
        </div>
      </div>
      <!--tit01 end-->
    
      <div class="ph">
        <h3 class="tit">点击排行</h3>
        <ul class="rank">
        <?php 
          @mysql_connect('localhost', 'root', 'root');
          mysql_select_db('blog');
          mysql_set_charset('utf8');
          $sql4 = "select * from `writing` order by `dianji` desc ";
          $res4 = mysql_query($sql4);
          while ($rows4 = mysql_fetch_assoc($res4)) {
              $arr4[] = $rows4;
}

        foreach ($arr4 as $v) {
          echo 
          '<li><a href="xiangqing.php?id='.$v['id'].'"  target="_blank">'.$v['title'].'</a></li>';
        } 
         ?> 
        </ul>
      </div>
      <div class="ad"> <img src="images/03.jpg"> </div>
    </div>
  </div>
  <!-- container代码 结束 -->

<?php 
include_once("public/after.php");
 ?>